package fanshe1;


import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

@SuppressWarnings("all")
public class TestPerson {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<Person> personClass = Person.class;
        System.out.println("personClass.getConstructors() = " + personClass.getConstructors());
        Constructor<Person> constructor = personClass.getConstructor(String.class, int.class);
        Person xiaoming = constructor.newInstance("小明", 30);
        Method sayHello = personClass.getMethod("sayHello");
        sayHello.invoke(xiaoming);
    }

}
